/*
 * NetworkSubSystem.h
 *
 *  Created on: Apr 16, 2017
 *      Author: zhangjf
 */

#ifndef SRC_NETWORKSUBSYSTEM_NETWORKSUBSYSTEM_H_
#define SRC_NETWORKSUBSYSTEM_NETWORKSUBSYSTEM_H_

#include <Poco/Logger.h>
#include <Poco/NotificationQueue.h>
#include <Poco/NotificationCenter.h>
#include <Poco/Util/Subsystem.h>

using namespace Poco::Util;

#include "NCSSubsystem.h"
#include "NCSTCPServer.h"
#include "PacketDispatcher.h"

using namespace network;
using namespace util;

namespace network
{

class NetworkSubsystem: public NCSSubsystem
{
public:
	NetworkSubsystem();
	virtual ~NetworkSubsystem();

	const char* name() const { return _name.c_str(); }
	const static NetworkSubsystem& instance() { return *_pInstance; }

	void start();
	void stop();

	//Logger& logger() const { return _logger; }

protected:
	void initialize(Application& self);
	void uninitialize();

	//void initLogger(const std::string& strLogName);

private:
	static const std::string _name;
	static NetworkSubsystem* _pInstance;

	NotificationQueue _nq;
	NotificationCenter _nc;
	NCSTCPServer _tcpServer;
	PacketDispatcher _packetDispatcher;
	//Poco::Logger& _logger;
};

} /* namespace network */

#endif /* SRC_NETWORKSUBSYSTEM_NETWORKSUBSYSTEM_H_ */
